package com.webchat.ugc.repository.dao;

import com.webchat.ugc.repository.entity.MessageQueueTask;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface IMessageQueueTaskDAO extends JpaRepository<MessageQueueTask, Integer> {


    Page<MessageQueueTask> findAllByStatus(Integer status, Pageable pageable);

    @Transactional
    @Modifying
    @Query(value = "update MessageQueueTask task set task.status = :status where task.taskId in :taskIdList")
    int batchUpdateStatus(List<String> taskIdList, Integer status);
}
